package drongo.desktop.menu
{
	import flash.display.NativeMenuItem;
	import flash.events.Event;
	
	public class DGNativeMenuItem extends NativeMenuItem
	{
		public function DGNativeMenuItem(label:String="", isSeparator:Boolean=false)
		{
			super(label, isSeparator);
			this.addEventListener(Event.SELECT,onSelect);
		}
		public function get toggled():Boolean { return checked; }
		
		public function set toggled(value:Boolean):void
		{
			if (checked == value)
				return;
			checked = value;
		}
		/**
		 * 获取操作KEY 
		 * @return 
		 */		
		public function get operation():String{
			return data.@value;
		}
		private function onSelect(e:Event):void{
			if(data.@type=="check"){
				toggled=!toggled;
				if(data is XML){
					data.@checked=toggled;
					data.@toggled=toggled;
				}
			}
		}
	}
}